; *** Thai chess
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com
(translate 
 ("White""白方")("Black" "黑方")
 ("Biar" "兵") ("Mar"  "马")
 ("Cone" "象") ("Ruar" "车")
 ("Met"  "士") ("Kune" "王")
 ("Makruk" "泰国象棋(Makruk)") ("Makruk (Double-Met Move)" "泰国象棋 - 挺士规则")
)
      

(define shift        ($1 (verify not-friend?) add) )
(define shift2       ($1 $2 (verify not-friend?) add) )
(define slide        ($1 (while empty? add $1) (verify not-friend?) add))
(define Biar-add
   (if (not-in-zone? promotion-zone) add) 
   (if (in-zone? promotion-zone) (add Met))
)
(define Biar-move
   (
      n
      (verify empty?)
      (Biar-add)
   )
)
(define Biar-capture
   (
      $1
      (verify enemy?)
      (Biar-add)
   )
)

(game
   (title "Makruk")
   (description "泰国象棋类似国际象棋，但走法与国象有很大不同，右键点击棋子查看走法。\\第二个玩法，挺士规则：士在未动过的前提下，还可以向前走两步。")
   (history "Makruk is an ancient variation of chess played in Thailand.  It is
      clearly related to Burmese and Japanese chess but is probably older than
      both, and may have influenced the development of shogi (the Bishop in
      Makruk is identical to Shogi's Silver General).   Makruk is currently very
      popular on Bangkok streets, but almost unknown outside of Thailand.   Makruk
      is much more popular than orthodox chess in Thailand, but the current 
      champion of Thai Chess, Suchart, is also a strong international player in
      orthochess.   David Pritchard remarks that, as with Chinese Chess, books
      on Makruk in Thai are easy to obtain and game transcripts can be read with
      a little study.")
   (strategy "Develop your pieces as soon as possible to control the center.
      Forge ahead with your Pawns, Queen, and Bishops and open up files for your
	Rooks.  Find good squares for your Knights, but watch out as they are
	vulnerable to attacks by Pawns, Queens, and Bishops.  If you're ahead
	keep enough material to checkmate.  Relative values of the pieces:\\
	Pawn - Queen - Bishop - Knight - Rook")
   (option "prevent flipping" 2)
   (music "")
   (opening-sound "Audio\\Asian.wav")
   (click-sound "Audio\\Pickup.wav")
   (release-sound "Audio\\WoodThunk.wav")
   (players White Black)
   (turn-order White Black)

   (board
      (image "images\Chess\Makruk.bmp")
      (grid
         (start-rectangle 5 5 52 52)
         (dimensions
             ("a/b/c/d/e/f/g/h" (49 0)) ; files
             ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
      )
      (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne))
      (zone
         (name promotion-zone)
         (players White)
         (positions a6 b6 c6 d6 e6 f6 g6 h6)
      )
      (zone
         (name promotion-zone)
         (players Black)
         (positions a3 b3 c3 d3 e3 f3 g3 h3)
      )
   )

   (board-setup
      (White
         (Biar a3 b3 c3 d3 e3 f3 g3 h3)
         (Mar b1 g1)
         (Cone c1 f1)
         (Ruar a1 h1)
         (Met e1)
         (Kune d1)
      )
      (Black
         (Biar a6 b6 c6 d6 e6 f6 g6 h6)
         (Mar b8 g8)
         (Cone c8 f8)
         (Ruar a8 h8)
         (Met d8)
         (Kune e8)
      )
   )

   (piece
      (name Biar)
      (image White "images\Chess\SHaag\wpawn.bmp" "images\Chess\wpawn.bmp"
             Black "images\Chess\SHaag\bpawn.bmp" "images\Chess\bpawn.bmp")
	  (help "兵：向前一格，吃子只能斜前一格。进入对方阵线第3行升级为士")
	  (description "兵\(泰语：Biar,或 Bia，贝壳，常用于兵卒的象征)\\只能前进一格，吃子只能斜前一格。进入对方阵线第3行（自己阵线来看是第6行）升变为士。")
      (moves
         (Biar-capture nw)
         (Biar-capture ne)
         (Biar-move)
      )
   )
   (piece
      (name Mar)
      (image White "images\Chess\SHaag\wknight.bmp" "images\Chess\wknight.bmp"
             Black "images\Chess\SHaag\bknight.bmp" "images\Chess\bknight.bmp")
	  (help "马：同国象马")
	  (description "马\(泰语：Mar,或Ma)\\走日字，即先横2步再竖1步，或先横1步再竖两步。可以越子。")
      (moves
	     (shift2 n ne)
	     (shift2 n nw)
	     (shift2 s se)
	     (shift2 s sw)
	     (shift2 e ne)
	     (shift2 e se)
	     (shift2 w nw)
	     (shift2 w sw)
      )
   )
   (piece
      (name Cone)
      (image White "images\Chess\SHaag\wbishop.bmp" "images\Chess\wbishop.bmp"
             Black "images\Chess\SHaag\bbishop.bmp" "images\Chess\bbishop.bmp")
	  (help "象：斜走一格，或向前一格")
	  (description "象\(泰语：Cone，或Khon ，意为贵族)\\走法与将棋的银将相同，即可以斜走一格，或者向前一格。")
      (moves
         (shift ne)
         (shift nw)
         (shift se)
         (shift sw)
		 (shift n)
      )
   )
   (piece
      (name Ruar)
      (image White "images\Chess\SHaag\wrook.bmp" "images\Chess\wrook.bmp"
             Black "images\Chess\SHaag\brook.bmp" "images\Chess\brook.bmp")
	  (help "车：直走不限格数。")
	  (description "车\ (泰语 Ruar 或 Rua，意为“船”)\\横竖均可，不限格数。")
      (moves
         (slide n)
         (slide e)
         (slide s)
         (slide w)
      )
   )
   (piece
      (name Met)
      (image White "images\Chess\SHaag\wqueen.bmp" "images\Chess\wqueen.bmp"
             Black "images\Chess\SHaag\bqueen.bmp" "images\Chess\bqueen.bmp")
	  (help "士：斜走一格。")
	  (description "士\(泰语Met，大臣)\\只能斜走一格。")
      (moves
         (shift ne)
         (shift nw)
         (shift se)
         (shift sw)
      )
   )
   (piece
      (name Kune)
      (image White "images\Chess\SHaag\wking.bmp" "images\Chess\wking.bmp"
             Black "images\Chess\SHaag\bking.bmp" "images\Chess\bking.bmp")
	  (help "王：八方一格，被将死输。")
	  (description "王\ (泰语：Kune 或 Khun)\\横、竖或斜走一格均可。被将死输。")
      (moves
         (shift n)
         (shift e)
         (shift s)
         (shift w)
         (shift ne)
         (shift nw)
         (shift se)
         (shift sw)
         
      )
   )
   (loss-condition (White Black) (checkmated Kune) )
)

; ********************************** VARIANTS

(define met-add (set-attribute never-moved? false) add)
(define met-shift ($1 (verify not-friend?) (met-add)) )

(variant
   (title "Makruk (Double-Met Move)")
   (piece
      (name Met)
      (image White "images\Chess\SHaag\wqueen.bmp" "images\Chess\wqueen.bmp"
             Black "images\Chess\SHaag\bqueen.bmp" "images\Chess\bqueen.bmp")
	  	  (help "士：斜走一格，若未动过，还可向前走两格。")
	  (description "士\(泰语Met，大臣)\\只能斜走一格。在未动过时，还可以向前走两格。")
      (attribute never-moved? true)
	  (moves
         (met-shift ne)
         (met-shift nw)
         (met-shift se)
         (met-shift sw)
         ( (verify never-moved?) n (verify empty?) n (verify empty?) (met-add) )
      )
   )
)
